package com.mayflygeek.mayflyask.framework.webmvc.message;

/**
 * @author 虫虫
 * @team 蜉蝣极客
 * @link www.mayflygeek.com
 * @Emial chongchong@mayflygeek.com
 * 
 */
public class MessageBuilder {
	private MessageType type;
	private String text;
	private String detail;
	private Object data;

	public MessageBuilder(MessageType type, String messageText) {
		this.type = type;
		this.text = messageText;
	}

	public Message build() {
		return new Message(type, text, detail, data);
	}

	public MessageBuilder type(MessageType type) {
		this.type = type;
		return this;
	}

	public MessageBuilder text(String text) {
		this.text = text;
		return this;
	}

	public MessageBuilder detail(String detail) {
		this.detail = detail;
		return this;
	}

	public MessageBuilder data(Object data) {
		this.data = data;
		return this;
	}

	public static MessageBuilder error(String error) {
		return new MessageBuilder(MessageType.error, error);
	}

	public static MessageBuilder success(String success) {
		return new MessageBuilder(MessageType.success, success);
	}

	public static MessageBuilder warning(String warning) {
		return new MessageBuilder(MessageType.warning, warning);
	}
}
